﻿using UnityEngine;
using FairyGUI;

public class FSuit : GLabel
{
    Suit _suitData;
    GTextField _discriptLabel;

    public override void ConstructFromXML(FairyGUI.Utils.XML cxml)
    {
        base.ConstructFromXML(cxml);

        _discriptLabel = this.GetChild("title").asTextField;
    }

    public void InitData(Suit suitData,bool isShowClickAni = true)
    {
        _suitData = suitData;
        Fresh();
    }

    public void Fresh(int level = 0)
    {
        if (_suitData == null) return;
        _discriptLabel.visible = true;
        //默认展示1级
        var discript = _suitData.GetSuitName();
        for(int i = 0;i < _suitData.numProperty.Count;i++){
            discript += "\n";
            discript += _suitData.GetPropertyDiscript(i);
        }
        if (_discriptLabel.text != discript) _discriptLabel.text = discript;
    }
}

